home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / global-one-water.swf / scripts / DefineSprite_431 / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2011-10-17  |  1.3 KB  |  57 lines

  1. function createUser()
  2. {
  3.    var _loc2_ = new LoadVars();
  4.    _loc2_.lId = 1;
  5.    _loc2_.name = _global.root.name = name_txt.text;
  6.    _loc2_.age = _global.root.age = 0;
  7.    _loc2_.sex = _global.root.sex = 0;
  8.    SO.setVar("age",0);
  9.    SO.setVar("sex",0);
  10.    SO.setVar("fanOf",0);
  11.    _loc2_.fanOf = 0;
  12.    _loc2_.score = _global.root.getScore();
  13.    _loc2_.r = Math.random();
  14.    _global.root.autosave = true;
  15.    submitAndShowThrobber(_loc2_);
  16. }
  17. function updateScore()
  18. {
  19.    var _loc2_ = new LoadVars();
  20.    _loc2_.lId = 1;
  21.    _loc2_.pId = _global.root.pId;
  22.    _loc2_.score = _global.root.getScore();
  23.    _loc2_.r = Math.random();
  24.    submitAndShowThrobber(_loc2_);
  25. }
  26. function submitAndShowThrobber(lv)
  27. {
  28.    lv.onLoad = scoreSubmitted;
  29.    lv.sendAndLoad(_global.backendURL + "comms/submitscore.comms.php",lv,"GET");
  30.    gotoAndStop("saving");
  31. }
  32. function scoreSubmitted(success)
  33. {
  34.    if(success)
  35.    {
  36.       if(this.result == "success")
  37.       {
  38.          if(!_global.root.pId)
  39.          {
  40.             _global.root.pId = Number(this.pId);
  41.             SO.setVar("pId",_global.root.pId);
  42.          }
  43.          gotoAndStop("saved");
  44.       }
  45.       else
  46.       {
  47.          trace("score submit failed 1: " + this.reason);
  48.          gotoAndStop("error");
  49.       }
  50.    }
  51.    else
  52.    {
  53.       trace("score submit failed 2");
  54.       gotoAndStop("error");
  55.    }
  56. }
  57.